package com.edu.ssm.controller;

import com.edu.ssm.domain.Emp;
import com.edu.ssm.mapper.EmpMapper;
import com.edu.ssm.service.EmpService;
import com.edu.ssm.service.impl.EmpServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("emp")
public class EmpController {
    @Autowired
    EmpService empService;

    @RequestMapping("query")
    public String queryEmp(ModelMap map) {
        List<Emp> emps = empService.queryEmps();
        map.addAttribute("emps", emps);
        return "index";
    }
    @RequestMapping("add")
    public String add(ModelMap map) {
        Emp emps=new Emp(null,"张三","程序员");
        empService.addEmps(emps);
        map.addAttribute("emps", emps);
        return "index";
    }

}
